package com.chima.service.impl;
import java.util.List;
import com.chima.dao.DepartmentDao;
import com.chima.dao.TastCenterDao;
import com.chima.domain.Department;
import com.chima.domain.TastCenterOperationcount;
import com.chima.domain.Taskcenterbouns;
import com.chima.domain.Taskcenterbounsstock;
import com.chima.domain.TastCentercoffe;
import com.chima.service.TastCenterService;

public class TastCenterServiceImp implements TastCenterService  {
	
	 private TastCenterDao tastCenterDao;
	 private DepartmentDao departmentDao;

	public void setTastCenterDao(TastCenterDao tastCenterDao) {
		this.tastCenterDao = tastCenterDao;
	}

	public DepartmentDao getDepartmentDao() {
		return departmentDao;
	}

	public void setDepartmentDao(DepartmentDao departmentDao) {
		this.departmentDao = departmentDao;
	}

	public void addOrModityTaskcenterbouns(double bouns, double costtotal,int worktotal, String date, int deptId) {
		Taskcenterbouns t=tastCenterDao.findTaskcenterbounsByDateAndDeptId(date, deptId);
		Department d=departmentDao.findById(deptId);
		if(t==null){
			Taskcenterbouns s=new Taskcenterbouns();
			s.setBouns(bouns);
			s.setDepartment(d);
			s.setDate(date);
			s.setCosttotal(costtotal);
			s.setTotalwork(worktotal);
			tastCenterDao.saveTaskcenterbouns(s);
			return;
		}
		t.setBouns(bouns);
		t.setCosttotal(costtotal);
		t.setTotalwork(worktotal);
		tastCenterDao.updateTaskcenterbouns(t);
		
	}
	public TastCentercoffe findTastCentercoffeById(int id) {
		return tastCenterDao.findTastCentercoffeById(id);
	}

	public List<TastCenterOperationcount> findTastCenterOperationcountByDateAnddept(String date, int dept) {
		
		return null;
	}

	public Taskcenterbounsstock findTaskcenterbounsstockByDateAndDeptId(String date, int deptId) {
		
		return tastCenterDao.findTaskcenterbounsstockByDateAndDeptId(date, deptId);
	}

	public void saveTaskcenterbouns(Taskcenterbouns taskcenterbouns) {
		
		tastCenterDao.saveTaskcenterbouns(taskcenterbouns);
		
	}

	public Taskcenterbouns findTaskcenterbounsByDateAndDeptId(String date,int deptId) {
		
		return tastCenterDao.findTaskcenterbounsByDateAndDeptId(date, deptId);
	}

	public TastCentercoffe findTastCentercoffeByNameAnddept(String name,int dept) {
		
		return tastCenterDao.findTastCentercoffeByNameAndDept(dept, name);
	}

	public void addOrModityTastCenterOperationcount(String operationName,int worktotal, String date, int operationId) {
		
		
	}

	

}
